import { createApp } from 'vue'

import App from './App.vue'
import router from './router/router'
import axios from "axios";
import ElementPlus, {ElMessage} from 'element-plus'
import 'element-plus/dist/index.css'
import store from './store'

axios.defaults.baseURL = 'http://localhost:8080';
const app=createApp(App)

export function getSessionStorage(keyStr) {
    var str = sessionStorage.getItem(keyStr);
    if (str == '' || str == null || str == 'null' || str == undefined) {
        return null;
    } else {
        return JSON.parse(str);
    }
}
//从sessionStorage中移除一个JSON对象
export function removeSessionStorage(keyStr) {
    sessionStorage.removeItem(keyStr);
}



app.config.globalProperties.$message = {
    success(content) {
        ElMessage({
            message: content,
            type: 'success',
        });
    },

    error(content) {
        ElMessage({
            message: content,
            type: 'error',
        });
    },
    warning(content) {
        ElMessage({
            message: content,
            type: 'warning',
        });
    },
};



//从localStorage中获取一个JSON对象（取不到时返回null）
export function getLocalStorage(keyStr) {
    var str = localStorage.getItem(keyStr);

    if (str == '' || str == null || str == 'null' || str == undefined) {
        return null;
    } else {
        return JSON.parse(str);
    }
}
//从localStorage中移除一个JSON对象
export function removeLocalStorage(keyStr) {
    localStorage.removeItem(keyStr);
}





app.use(router)
app.use(store)
app.use(ElementPlus)

app.mount('#app')
